//
// Created by Semir on 2020/4/14.
//

#include <iostream>

using namespace std;

const int MAX_N = 20;
const int MAX_M = 100005;
int m;
int value[MAX_N];
int dp[MAX_M];

int main() {
    cin >> m;
    int n = 0;
    for (; n < MAX_N; n++) {
        value[n] = n * n * n * n;
        if (value[n] > m) {
            break;
        }
    }
    for (int i = 0; i <= m; i++) {
        dp[i] = i;
    }
    for (int i = 2; i <= n; i++) {
        for (int j = value[i]; j <= m; j++) {
            dp[j] = min(dp[j], dp[j - value[i]] + 1);
        }
    }
    cout << dp[m] << endl;
    return 0;
}